package com.movitech.mobile.cz.base.purchase.bizcontroller;

import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.purchase.service.WFlowFormQuestionAnswerService;
import com.movitech.mobile.cz.base.purchase.service.WFlowFormSuppliersQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * Created by Administrator on 2018/3/29.
 */
@RestController
@RequestMapping("/v1/purchaseQuestionAnswer")
@Api(value = "供方答疑补遗接口", description = "供方答疑补遗接口")
public class PurchaseQuestionAnswerController {

    @Autowired
    private WFlowFormSuppliersQuestionService wFlowFormSuppliersQuestionService;

    @Autowired
    private WFlowFormQuestionAnswerService wFlowFormQuestionAnswerService;

    @GetMapping("/getSuppliersQuestion/{flowId}")
    @ApiOperation(
            value = "答疑补遗-供方质疑详情接口",
            notes = "答疑补遗-供方质疑详情接口"
    )
    public RestReturnResult getSuppliersQuestion(@PathVariable String flowId) {
        RestReturnResult<Object> hResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        try{
            hResult=wFlowFormSuppliersQuestionService.getSuppliersQuestion(flowId);
        }catch(Exception e){
            e.printStackTrace();
            hResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[1], CommonConstants.ERROR_DESCS[1]);
        }
        return hResult;
    }

    @GetMapping("/getQuestionAnswer/{flowId}")
    @ApiOperation(
            value = "答疑补遗详情接口",
            notes = "答疑补遗详情接口"
    )
    public RestReturnResult getQuestionAnswer(@PathVariable String flowId) {
        RestReturnResult<Object> hResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        try{
            hResult=wFlowFormQuestionAnswerService.getQuestionAnswer(flowId);
        }catch(Exception e){
            e.printStackTrace();
            hResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[1], CommonConstants.ERROR_DESCS[1]);
        }
        return hResult;
    }
}
